//
//  SYVisitorViewController.swift
//  SYWeibo
//
//  Created by Eric on 16/7/19.
//  Copyright © 2016年 Eric. All rights reserved.
//

import UIKit

class SYVisitorViewController: UIViewController {
    //判断用户是否登录
    var isLogin: Bool = SYUserAccountViewModel.sharedTools.isLogin
    

    
    //访客视图view
    var visitorView: SYVisitorView?
    
    //MARK: - 监听方法
    @objc private func loginClick(){
        //加载授权界面
        let oauthVC = SYOAuthViewController()
        //modal 出来视图
        presentViewController(UINavigationController(rootViewController: oauthVC), animated: true, completion: nil)
   

        
    }

    //加载 view
    override func loadView() {
        
        isLogin ? (view = tableVeiw) : setupVisitorView()
    }
    
    
    //设置访客视图
    func setupVisitorView(){
    visitorView = SYVisitorView()
        visitorView?.closure = {[weak self] in
            self?.loginClick()
        }
        view = visitorView
        setupNav()
    }
    
    //MARK: - 设置导航按钮

    func setupNav(){
    navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: "loginClick")
    navigationItem.rightBarButtonItem = SYBarButtonItem(title: "注册", taget: self, action: "loginClick")
    
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }
    //MARK: - 懒加载一个 tableView
    lazy var tableVeiw: UITableView = UITableView()

    
}
